﻿// -----------------------------------------------------------------------
// <copyright file="CustomModel.cs" company="">
// TODO: Update copyright text.
// </copyright>
// -----------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using StampController.Core;

namespace StampController.BL.Models
{
    public partial class UsersModel
    {
        public string DeptName { get; set; }
    }

    public partial class ApprovalHistoryModel
    {
        public string Fullname { get; set; }
        public string DeptName { get; set; }

        public string StatusName
        {
            get
            {
                if (Common.ApprovalStatusDic.ContainsKey(Status))
                return Common.ApprovalStatusDic[Status];
                return string.Empty;
            }
        }
        public string Preposition
        {
            get
            {
                if (Common.PrepositionDic.ContainsKey(Status))
                    return Common.PrepositionDic[Status];
                return string.Empty;
            }
        }
        public string ApprovedDateText { get { return ApprovedDate.ToShortDateString(); } }
    }


    public partial class AuthorizedHistoryModel
    {
        public bool Todo { get { return EndDate > DateTime.Now; } }
        public string CreatedName { get; set; }
        public string DelegateMail { get; set; }
        public string StartDateText { get { return StartDate.ToString(CultureInfo.InvariantCulture); } }
        public string EndDateText { get { return EndDate.ToString(CultureInfo.InvariantCulture); } }
    }

    public partial class FeedbackModel
    {
        public string FeedbackTimeText { get { return FeedbackTime.ToString(); } }
    }

    /// <summary>
    ///     TODO: Update summary.
    /// </summary>
    public partial class RequestFormModel
    {
        public string StampName
        {
            get
            {
                if (Common.StampDic.ContainsKey(StampID))
                    return Common.StampDic[StampID];
                return string.Empty;
            }
        }

        public string STName
        {
            get
            {
                string s = Common.StampTypeDic.Where(stampType => STID.Has(stampType.Key))
                    .Aggregate(string.Empty,
                        (current, stampType) => current + ('+' + Common.StampTypeDic[stampType.Key]));
                if (!string.IsNullOrEmpty(s))
                    return s.Substring(1);
                return string.Empty;
            }
        }

        public List<int> STList { get; set; }

        public string RequestTypeName
        {
            get
            {
                if (Common.RequestTypeDic.ContainsKey(RequestType))
                    return Common.RequestTypeDic[RequestType];
                return string.Empty;
            }
        }

        public string RequiredByName
        {
            get
            {
                if (Common.RequiredTypeDic.ContainsKey(RequiredBy))
                    return Common.RequiredTypeDic[RequiredBy];
                return string.Empty;
            }
        }

        public string SignByName
        {
            get
            {
                if (Common.SignByDic.ContainsKey(SignByID))
                    return Common.SignByDic[SignByID];
                return string.Empty;
            }
        }

        public string DateRequestText
        {
            get { return DateRequest.ToShortDateString(); }
        }

        public string DateNeededText
        {
            get
            {
                if (DateNeeded.HasValue)
                    return DateNeeded.Value.ToShortDateString();
                return string.Empty;
            }
        }

        public string DeptName { get; set; }
        public string CateName { get; set; }
        public string CreatedBy { get; set; }
        public string RequestForName { get; set; }
        public string ApprovedName { get; set; }
        public List<DocumentModel> DocumentList { get; set; }
        public IList<ApprovalHistoryModel> ApprovalHistoryList { get; set; }
    }
}